I may be missing something here. But I wonder how to figure out which item is selected in a single ListView when Sorting is allowed.
llandale - Thu Sep 08 10:52:57 EDT 2011 |
Re: ListView Selection
Hmm I thought you would be able to use the client data field on the rows, but obviously at least for DOORS 8.2 this is implemented buggy. As soon as you add the listViewOptionSortText at the creation of the listview, then the below code crashes. Until this is fixed I guess you either need that index column (make it width 0) or stay away from sorting. Regards, Mathias
int fDbeLv_clbkSortFunction(string s1, s2)
{ // Standard sort function when defining a column as sortable.
// Developers Note: Some code if added herein will cause DXL exception Violations.
// Don't understand why, but this function needs to be kept as-is.
int Result
print "S1 = " s1 " S2 = " s2 "\n"
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
elseif (s1 < s2) Result = -1
else{} // all cases covered
return(Result)
} // end fDbeLv_clbkSortFunction()
DBE lv
void activateModule (DBE x, int index) {
print "I = " index " activated!\n"
if (index < 0) return
Buffer s = (getClientData(lv, index)) Buffer
print s "\n"
}
string someData[] = {}
DB testDialog = centered "Listview Test"
label (testDialog, "" )
// remove the listViewOptionSortText and the code will not crash
lv = listView (testDialog,listViewOptionSortText, 200, 5, someData)
realize testDialog
insertColumn(lv, 0, "Column 1" , 80, iconNone)
insertColumn(lv, 1, "Column 2" , 80, iconNone)
set (lv, 0, 1, "Some Data")
set (lv, 1, 1, "More Data")
set(lv, 0, fDbeLv_clbkSortFunction)
set(lv, 1, fDbeLv_clbkSortFunction)
void dummyCallback(DBE, int) {}
set(lv, dummyCallback, dummyCallback, activateModule)
Buffer b1 = create(); b1 = "This is Index 1"
Buffer b2 = create(); b2 = "This is Index 2"
insert(lv, 0, "Line 1", b1, iconNone)
insert(lv, 1, "Line 2", b2, iconNone)
show testDialog
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: ListView Selection Mathias Mamsch - Thu Sep 08 16:55:40 EDT 2011
Hmm I thought you would be able to use the client data field on the rows, but obviously at least for DOORS 8.2 this is implemented buggy. As soon as you add the listViewOptionSortText at the creation of the listview, then the below code crashes. Until this is fixed I guess you either need that index column (make it width 0) or stay away from sorting. Regards, Mathias
int fDbeLv_clbkSortFunction(string s1, s2)
{ // Standard sort function when defining a column as sortable.
// Developers Note: Some code if added herein will cause DXL exception Violations.
// Don't understand why, but this function needs to be kept as-is.
int Result
print "S1 = " s1 " S2 = " s2 "\n"
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
elseif (s1 < s2) Result = -1
else{} // all cases covered
return(Result)
} // end fDbeLv_clbkSortFunction()
DBE lv
void activateModule (DBE x, int index) {
print "I = " index " activated!\n"
if (index < 0) return
Buffer s = (getClientData(lv, index)) Buffer
print s "\n"
}
string someData[] = {}
DB testDialog = centered "Listview Test"
label (testDialog, "" )
// remove the listViewOptionSortText and the code will not crash
lv = listView (testDialog,listViewOptionSortText, 200, 5, someData)
realize testDialog
insertColumn(lv, 0, "Column 1" , 80, iconNone)
insertColumn(lv, 1, "Column 2" , 80, iconNone)
set (lv, 0, 1, "Some Data")
set (lv, 1, 1, "More Data")
set(lv, 0, fDbeLv_clbkSortFunction)
set(lv, 1, fDbeLv_clbkSortFunction)
void dummyCallback(DBE, int) {}
set(lv, dummyCallback, dummyCallback, activateModule)
Buffer b1 = create(); b1 = "This is Index 1"
Buffer b2 = create(); b2 = "This is Index 2"
insert(lv, 0, "Line 1", b1, iconNone)
insert(lv, 1, "Line 2", b2, iconNone)
show testDialog
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
As Mathias says, sort functions are very buggy. Do not try to do anything clever in the callback - it always blows up. Tony Goodman, www.smartdxl.com |
Re: ListView Selection Mathias Mamsch - Thu Sep 08 16:55:40 EDT 2011
Hmm I thought you would be able to use the client data field on the rows, but obviously at least for DOORS 8.2 this is implemented buggy. As soon as you add the listViewOptionSortText at the creation of the listview, then the below code crashes. Until this is fixed I guess you either need that index column (make it width 0) or stay away from sorting. Regards, Mathias
int fDbeLv_clbkSortFunction(string s1, s2)
{ // Standard sort function when defining a column as sortable.
// Developers Note: Some code if added herein will cause DXL exception Violations.
// Don't understand why, but this function needs to be kept as-is.
int Result
print "S1 = " s1 " S2 = " s2 "\n"
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
elseif (s1 < s2) Result = -1
else{} // all cases covered
return(Result)
} // end fDbeLv_clbkSortFunction()
DBE lv
void activateModule (DBE x, int index) {
print "I = " index " activated!\n"
if (index < 0) return
Buffer s = (getClientData(lv, index)) Buffer
print s "\n"
}
string someData[] = {}
DB testDialog = centered "Listview Test"
label (testDialog, "" )
// remove the listViewOptionSortText and the code will not crash
lv = listView (testDialog,listViewOptionSortText, 200, 5, someData)
realize testDialog
insertColumn(lv, 0, "Column 1" , 80, iconNone)
insertColumn(lv, 1, "Column 2" , 80, iconNone)
set (lv, 0, 1, "Some Data")
set (lv, 1, 1, "More Data")
set(lv, 0, fDbeLv_clbkSortFunction)
set(lv, 1, fDbeLv_clbkSortFunction)
void dummyCallback(DBE, int) {}
set(lv, dummyCallback, dummyCallback, activateModule)
Buffer b1 = create(); b1 = "This is Index 1"
Buffer b2 = create(); b2 = "This is Index 2"
insert(lv, 0, "Line 1", b1, iconNone)
insert(lv, 1, "Line 2", b2, iconNone)
show testDialog
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
After my post I did find this command: getColumnValue(DBE lv, int iRow, int iColumn) which means my KEY column need not be the first one. Thanks
|
Re: ListView Selection Tony_Goodman - Fri Sep 09 11:26:06 EDT 2011 I wonder if you can re-define the callback such that you can enforce a reverse sort on demand. It would getSortColumn and if its the same column, reverse the sort order.
|